package org.itboys.seller;

import org.itboys.admin.constant.AdminSessionConstant;
import org.itboys.commons.utils.ajax.AjaxUtils;
import org.itboys.commons.utils.servlet.ServletContextHolder;
import org.itboys.framework.spring.controller.BaseController;
import org.itboys.mongodb.utils.query.QueryParamUtils;
import org.itboys.shop.entity.ScenicSpot;
import org.itboys.shop.service.ScenicSpotService;
import org.itboys.shop.service.TouristService;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.List;
import java.util.Map;

/**
 * Created by Administrator on 2016/7/7.
 */
@RestController
@RequestMapping("/scenicTourist")
public class ScenicTouristController extends BaseController {

    @Resource
    private TouristService touristService;
    @Resource
    private ScenicSpotService scenicSpotService;

    /**
     * 获取景区下的景点
     * @return
     */
    @RequestMapping("/findAllTourist")
    public void findAllCity(@RequestParam("scenicId") long scenicId,
                            HttpServletRequest request , HttpServletResponse response){
        AjaxUtils.renderJson(response, touristService.findAllTourist(scenicId));
    }

    /**
     * 返回所有列表
     * @param response
     * @param request
     */
    @RequestMapping("/allList")
    public void allList(HttpServletResponse response,
                        HttpServletRequest request) {
        final Map<String, Object> sqlMap = QueryParamUtils.builderQueryMap(request);
        long centerId = (Long) ServletContextHolder.getSession().getAttribute(AdminSessionConstant.SHOP_CENTER_ID);
        sqlMap.put("centerId", centerId);
        List<ScenicSpot> list = scenicSpotService.list(sqlMap);
        AjaxUtils.renderJson(response, list);
    }

}
